package com.rico.kok.controller.handler;

import com.rico.kok.tool.MessageUtils;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionHandler {

    @Autowired
    MessageUtils messageUtils;

    @ExceptionHandler(value = AuthorizationException.class)
    public String authorizationExceptionHandler(){
        return "login";
    }

    @ExceptionHandler(value = NumberFormatException.class)
    public String NumberFormatExceptionExceptionHandler(Model model){
        messageUtils.setMsg(model,"格式不正确的ID！","error");
        return "msg";
    }
}
